const controller = (data) => {
    let template = `
        import {
          Controller,
          Inject,
          Get,
          Query,
          Body,
          Post,
          Param,
          Del,
        } from '@midwayjs/core';
        import { ${data.da}Service } from '@service/${data.folder}/${data.xiao}.service';
        import {
          List${data.da}DTO,
        } from '@dto/${data.folder}/${data.xiao}.dto';
        import { BusinessType, Log } from '@decorator/log.decorator';
        
        @Controller('/${data.folder}/${data.xiao}')
        export class PostController {
          @Inject()
          ${data.da}Service: ${data.da}Service;
        
          // 获取列表
          @Get('/list')
          async list(@Query() queryParams: List${data.da}DTO) {
            return await this.${data.da}Service.list(queryParams);
          }
        
          // 新增
          @Log({ title: '${data.text}新增', businessType: BusinessType.ADD })
          @Post('/add')
          async create(@Body() ${data.da}: any) {
            return await this.${data.da}Service.create(${data.da});
          }
        
          // 删除
          @Log({ title: '${data.text}删除', businessType: BusinessType.REMOVE })
          @Del('/:${data.da}Id')
          async delete(@Param('${data.da}Id') ${data.da}Id: string) {
            return await this.${data.da}Service.delete(${data.da}Id);
          }
        
          // 修改
          @Log({ title: '${data.text}修改', businessType: BusinessType.EDIT })
          @Post('/update')
          async update(@Body() ${data.da}: any) {
            return await this.${data.da}Service.update(${data.da});
          }
        
          // 获取${data.text}详情
          @Get('/:${data.da}Id')
          async get(@Param('${data.da}Id') ${data.da}Id: string) {
            return await this.${data.da}Service.detail(${data.da}Id);
          }
        }
    `

    return template
}




export default controller
